package cn.edu.lingnan.servlet.club;

import cn.edu.lingnan.pojo.Club;
import cn.edu.lingnan.pojo.Student;
import cn.edu.lingnan.service.ClubService;
import cn.edu.lingnan.service.ClubServiceMysqlImpl;
import cn.edu.lingnan.service.StudentService;
import cn.edu.lingnan.service.StudentServiceMysqlImpl;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/admin/club/updateClub")
public class UpdateClubServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String cid=req.getParameter("cid");
        String cname=req.getParameter("cname");
        String cflag=req.getParameter("cflag");
        Club club=new Club(cid,cname,cflag);
        System.out.println("要修改的社团信息："+club);
        ClubService service=new ClubServiceMysqlImpl();
        boolean flag=service.updateClub(club);
        if(flag){
            System.out.println("修改成功");
        }else{
            System.out.println("修改失败");
        }
        resp.sendRedirect("/club/queryAllClub");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
